/*
1.该文件是为创建一个为count服务的reducer
2.reducer函数会接收到两个参数，分别为之前的状态，动作对象
*/
import {Decrement, Increment} from "./constant";

const initState = 0
export default function countReducer(preState = initState, action) {
    console.log(preState, action)
    let {type, data} = action
    switch (type) {
        case Increment:
            return preState + data
        case Decrement:
            return preState - data
        default:
            return preState
    }
}